package com.wwfish.cms.service.sysuser;

import com.nexustar.gwt.widgets.client.model.PaginationModelDto;
import com.wwfish.cms.model.sysuser.SysUserDto;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2010-8-22
 * Time: 7:04:42
 * To change this template use File | Settings | File Templates.
 */
public class SysUserManagerImpl implements SysUserManager {
    private List<SysUserDto> cache = new ArrayList();

    public SysUserDto saveAndUpdate(SysUserDto dto) {
        if (dto.getId() == null) {
            dto.setId(new Long((int) (Math.random() * 10000)));
            dto.setCreateTime(new Date());
            cache.add(dto);
        } else
            dto.setUpdateTime(new Date());

        return dto;
    }

    public void delete(SysUserDto dto) {
        cache.remove(dto);
    }

    public PaginationModelDto<SysUserDto> getPageEntities(Integer begin, Integer count, Map<String, String> conditions) {
        PaginationModelDto dto = new PaginationModelDto(new ArrayList(), 0);
        return dto;
    }

    public Boolean isExitLoginName(String loginName) {
        return ((int) (Math.random() * 10)) % 2 == 1;
    }
}
